#if !defined(AFX_CLIENTSOCKETTHREAD_H__1D522EEC_5168_457B_B309_4D630F470F14__INCLUDED_)
#define AFX_CLIENTSOCKETTHREAD_H__1D522EEC_5168_457B_B309_4D630F470F14__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// ClientSocketThread.h : header file
//


class Packet;
class CClientSocket;

/////////////////////////////////////////////////////////////////////////////
// CClientSocketThread thread

class CClientSocketThread : public CWinThread
{
	DECLARE_DYNCREATE(CClientSocketThread)
protected:
	CClientSocketThread();           // protected constructor used by dynamic creation

// Attributes
public:
  CString m_strServerIPAddress;
  int m_nPort;
  SOCKET m_hSocket;
  std::list<Packet *> m_PacketsIn;
  std::list<Packet *> m_PacketsOut;
  CMutex m_mutexPacketsIn;
  CMutex m_mutexPacketsOut;

protected:
  CClientSocket * m_pSocket;

// Operations
public:
  void DeleteInstance();
  void AddPacketReceived(Packet * pPacket);
  void AddPacketToSend(Packet * pPacket);
  Packet * TakePacketToSend(DWORD dwId = 0);
  Packet * TakePacketReceived(DWORD dwId = 0);
  DWORD TakeSizeOfPacketReceived(DWORD dwId = 0);
  void ClearOrphanPacketsIn();
  void ClearOrphanPacketsOut();

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CClientSocketThread)
	public:
	virtual BOOL InitInstance();
	virtual int ExitInstance();
	//}}AFX_VIRTUAL

// Implementation
protected:
	virtual ~CClientSocketThread();

	// Generated message map functions
	//{{AFX_MSG(CClientSocketThread)
		// NOTE - the ClassWizard will add and remove member functions here.
	//}}AFX_MSG
  afx_msg LRESULT OnExitSocketThread(WPARAM wParam, LPARAM lParam);
  afx_msg LRESULT OnSendTo(WPARAM wParam, LPARAM lParam);
	DECLARE_MESSAGE_MAP()
};

/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_CLIENTSOCKETTHREAD_H__1D522EEC_5168_457B_B309_4D630F470F14__INCLUDED_)
